/*
** register_error_label_syntax.c for asm in /home/vanet_c//proj-kw/asm/folder_syntax
** 
** Made by charles-edouard vanet
** Login   <vanet_c@epitech.net>
** 
** Started on  Fri Dec 14 14:49:34 2012 charles-edouard vanet
** Last update Sat Dec 15 17:58:30 2012 charles-edouard vanet
*/

#include	"../../includes/asm.h"

void	register_msg(t_list **list, t_my_file **my_file, char *error)
{
  my_fd_putchar('\t', 2);
  my_stderror((*list)->name);
  my_stderror(" : no such register line ");
  my_put_nbr_error((*my_file)->line_nb);
  my_fd_putchar('\n', 2);
  if (error != '\0')
    aff_char_error(my_file, error);
  my_free_list(*list);
  my_stderror("\n\e[1mAssembling aborted on error.\e[0m\n");
  exit(EXIT_FAILURE);
}

int	label_syntax(t_list **list, t_my_file **my_file)
{
  int	t;
  
  t = -1;
  if ((*list)->tmp_for_label != NULL)
    my_free_tab((*list)->tmp_for_label);
  while ((*my_file)->tab_instruction[++t] != NULL)
    {
      if ((*my_file)->tab_instruction[t][0] != '\0' &&
	  (*my_file)->tab_instruction[t][my_strlen((*my_file)->tab_instruction[t]) - 1]
	  == LABEL_CHAR)
	{
	  (*list)->tmp_for_label = (*my_file)->tab_instruction;
	  (*my_file)->tab_instruction =
	    my_str_to_wordtab((*my_file)->tab_instruction,
			      (*my_file)->instruction +
			      my_strlen((*my_file)->tab_instruction[t]) + 1, ", ");
	  check_order(list, my_file);
	  (*my_file)->tab_instruction = (*list)->tmp_for_label;
	}
    }
  return (0);
}
